package day05;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <a href="https://leetcode-cn.com/problems/binary-tree-paths/">257. 二叉树的所有路径</a>
 */
public class Answer {

    static List<String> list = new ArrayList<>();

    static Map<Integer, String> map = new HashMap<>();

    static int nums = 0;

    static String stringBuilder = "";

    public static void main(String[] args) {

        binaryTreePaths(init());
        System.out.println(map);
    }

    public static void binaryTreePaths(TreeNode root) {
        if (root == null) {
            ++nums;
            map.put(nums, stringBuilder);
            return;
        }
        stringBuilder += root.val;
        binaryTreePaths(root.left);
        binaryTreePaths(root.right);
    }

    public static TreeNode init() {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(3);
        root.left.left = new TreeNode(4);
        root.left.right = new TreeNode(5);
        return root;
    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }
}
